<!--title-->
<div class="mnav1">
	<div class="m_nav">
		<div class="nav_left">
			<em class="home_icon"><?=$this->sys_name?></em><span>&nbsp;&gt;&nbsp;</span><font><?=$this->title?></font>
		</div>
	</div>
</div>

<div class="content-table">
<div class="content-table-title"><?=$this->title?></div>
<br />
<?php if($this->msg):?>
<div class="replace"><?=$this->msg?></div>
<br />
<?php endif;?>
<form action="/clients/signers" name="form1" method="GET">
省：<select name="provinceId" id="provinceId" onchange="GetCities(this.options[this.options.selectedIndex].value);">
	<option value="">不限</option>
	<?php if(!empty($this->provinces)):?>
	<?php foreach($this->provinces as $provinceId => $provinceName):?>
	<option value="<?=$provinceId?>" <?php if($provinceId==$this->provinceId){echo "selected='selected'";}?>><?=$provinceName?></option>
	<?php endforeach;?>
	<?php endif;?>
</select>
&nbsp;&nbsp;
市：<select name="cityId" id="cityId">
		<option value="">不限</option>
		<?php if(!empty($this->init_cities)):?>
		<?php foreach($this->init_cities as $init_cities):?>
		<option value="<?=$init_cities['cityId']?>" <?php if($init_cities['cityId']==$this->cityId){echo "selected='selected'";}?>><?=$init_cities['cityName']?></option>
		<?php endforeach;?>
		<?php endif;?>
	</select>
&nbsp;&nbsp;&nbsp;&nbsp;
状态：
<input type="checkbox" name="status[]" id="status_1" value="1" <?php if(in_array(1, $this->status)){echo "checked='checked'";}?> /> <label for="status_1">正常</label>&nbsp;&nbsp;&nbsp;
<input type="checkbox" name="status[]" id="status_0" value="0" <?php if(in_array(0, $this->status)){echo "checked='checked'";}?> /> <label for="status_0">待审核</label>&nbsp;&nbsp;&nbsp;
<input type="checkbox" name="status[]" id="status_2" value="2" <?php if(in_array(2, $this->status)){echo "checked='checked'";}?> /> <label for="status_2">未通过</label>&nbsp;&nbsp;&nbsp;
<br>
关键字：<input type="text" name="keyword" <?php if($this->keyword){echo "value='".$this->keyword."'";}?> />
&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" class="button" value="搜索" />
&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" class="button-cancle" value="清空搜索条件" onclick="location.href='?';" />
&nbsp;&nbsp;&nbsp;&nbsp;
<font color="red"><b>当前搜索结果: 签约公司数 <?=$this->data['ct']?></b></font>
&nbsp;&nbsp;&nbsp;&nbsp;
<a href="/clients/add-signer"><font color="green"><b>【新增签约公司】</b></font></a>
</form>
<br />
<table>
  <tr>
    <th>签约公司全称</th>
    <th>法定代表人</th>
    <th>电话</th>
    <th>营业执照注册号</th>
    <th>年检到期日</th>
    <th>申请人</th>
    <th>申请日期</th>
    <th>状态</th>
    <th>操作</th>
  </tr>
  <?php $data = $this->data['current_page_info'];?>
  <?php if($data["company_name"]):?>
  <?php foreach($data["company_name"] as $id => $something):?>
  <tr>
    <td><?=$data["company_name"][$id]?></td>
    <td><?=$data["company_owner"][$id]?></td>
	<td><?=$data["tel"][$id]?></td>
	<td><?=$data["business_number"][$id]?></td>
	<td><?=$data["business_expired_date"][$id]?></td>
	<td><?=$data["emp_name"][$id]?></td>
	<td><?=$data["ctime"][$id]?></td>
	<td><?php if(1==$data["status"][$id]){echo "<font color='green'>正常</font>";}elseif(2==$data["status"][$id]){echo "<font color='grey'>未通过</font>";}else{echo "<font color='red'>待审核</font>";}?></td>
	<td>
		<?php if("LEVEL-3" == $_SESSION['identity']['level']):?>
			<?php if(0 == $data["status"][$id]):?>
			<button onclick="SignerOpt(<?=$id?>, 1)">通过</button>&nbsp;&nbsp;<button onclick="SignerOpt(<?=$id?>, 2)">驳回</button>
			<?php elseif(1 == $data["status"][$id]):?>
			<button onclick="SignerOpt(<?=$id?>, 2)">撤销</button>
			<?php elseif(2 == $data["status"][$id]):?>
			<button onclick="SignerOpt(<?=$id?>, 1)">再次通过</button>
			<?php endif;?>
		<?php elseif($data["emp_id"][$id] == $_SESSION['identity']['userid']):?>
			<?php if(0 == $data["status"][$id]):?>
			<button onclick="SignerOpt(<?=$id?>, 2)">撤销</button>
			<?php endif;?>
		<?php endif;?>
		<button onclick="window.window.open('/clients/edit-signer/signer_id/<?=$id?>')">编辑</button>
	</td>
  </tr>
  <?php endforeach;?>
  <?php endif;?>
</table>

<br /><br />
<div align="right"><?=$this->pagination?></div>
<br /><br /><br />

<script>
function GetCities(provinceId)
{
	$.ajax({
			type: "post",
			url : "/ajax/get-cities",
			dataType:'json',
            async:false,
			data: {
					'provinceId':provinceId
				  },
				success: function(json){
					if(json.result == 1 && typeof(json.data) != "undefined") {
                        var arr = json.data;
						var txt = "<option value=''>不限</option>";
						
                        for(i=0; i < arr.length; i++){
							txt += "<option value='" + arr[i]['cityId'] + "'>" + arr[i]['cityName'] + "</option>";
                        }
						
						document.getElementById("cityId").innerHTML = txt;
                    }
			}
		});
}

function SignerOpt(id, status)
{
	$.ajax({
			type: "post",
			url : "/ajax/signer-opt",
			dataType:'json',
            async:false,
			data: {
					'id':id,
					'status':status
				  },
				success: function(json){
					if(json.result == 1) {
                        window.location.href = "/clients/signers/status/2";
                    }else{
						window.location.href = "/clients/signers/status/3";
					}
			}
		});
}
</script>